// Fill out your copyright notice in the Description page of Project Settings.

#pragma once


#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Interface/HitInterface.h"
#include "BreakableActor.generated.h"

class UGeometryCollectionComponent;

UCLASS()
class NEWMYPROJECT2_API ABreakableActor : public AActor, public IHitInterface
{
	GENERATED_BODY()
	
public:	
	ABreakableActor();
	virtual void Tick(float DeltaTime) override;

	virtual void GetHit_Implementation(const FVector& ImpactPoint, AActor* Hitter) override;
protected:
	virtual void BeginPlay() override;

	int32 SelectRandomIndex(const TArray<TSubclassOf<class ATreasure>>& Treasures);

	UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
	UGeometryCollectionComponent* GeometryCollection;

	UPROPERTY(VisibleAnywhere,BlueprintReadWrite)
	class UCapsuleComponent* Capsule;

	UFUNCTION()
	void BreakSwapanActor(const FChaosBreakEvent& BreakEvent);
private:	
	UPROPERTY(EditAnywhere, Category = "Breakbale Properties")
	TArray<TSubclassOf<class ATreasure>>TreasureClases;

	bool bBroken = false;

	bool bExist = false;
};
